<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set value="${pageContext.request.contextPath}" var="path"></c:set>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>车辆查看</title>
    <script type="text/javascript" src="${path}/static/web/js/jquery-3.6.0.min.js"></script>
    <script type="text/javascript" src="${path}/static/web/js/showParking.js" charset="UTF-8"></script>
    <link rel="stylesheet" type="text/css" href="${path}/static/web/css/MsgStyle.css"/>
</head>
<body>
<div class="div_container" id="pageListTable">
    <!-- 查看车辆-->
    <table style=" margin:50px auto;" border="1" width="300">
        <thead>
        <tr>
            <th>车牌号</th>
            <th>删除</th>
            <th>修改</th>
        </tr>
        </thead>
        <tbody id="pageListTableBody" >
        <c:forEach items="${requestScope.carList}" var="car">
            <tr>
                <td>${car.license}</td>
                <td><a data-id="${car.id}" href="javascript:void(0);" class="delete">删除</a></td>
                <td><a href="${path}/web/updatecar?id=${car.id}">修改</a></td>
            </tr>
        </c:forEach>
        </tbody>
        <tfoot>
        <tr><td colspan="3">
            <div id="pages" style="float: right;margin-right: 20px;">
                <span id="spanFirst">首页</span>
                <span id="spanPre">上一页</span>
                <span id="spanNext">下一页</span>
                <span id="spanLast">尾页</span>
                第<strong id="spanPageNum"></strong>页/共
                <strong id="spanTotalPage"></strong>页
            </div>
        </td>
        </tr>
        </tfoot>
    </table>
</div>
    <!-- 给删除添加点击的事件 -->
    <script type="text/javascript">
        $(function(){
            $(".delete").click(deleteOne);
        });

        function deleteOne()
        {
            var id = $(this).data("id");

            $.ajax({
                url:"/project/web/deleteCarName",
                type:"get",
                data:{id:id},
                success:function(mes){
                    $(this).parent().parent().remove();
                }.bind(this)
            });
        }
    </script>
</body>
</html>
